// ++++++++++++++++++++++++++++++++++++++++
// 《零基础Go语言算法实战》源码
// ++++++++++++++++++++++++++++++++++++++++
// Author:廖显东（ShirDon）
// Blog:https://www.shirdon.com/
// Gitee:https://gitee.com/shirdonl/goAlgorithms.git
// Buy link :https://item.jd.com/14101229.html
// ++++++++++++++++++++++++++++++++++++++++

package main

import "sync"

type threadSafeMap struct {
	ages map[string]int
	sync.Mutex
}

func (set *threadSafeMap) Iteration() <-chan interface{} {
	ch := make(chan interface{})
	go func() {
		set.Lock()

		for elem := range set.ages {
			ch <- elem
		}

		close(ch)
		set.Unlock()

	}()
	return ch
}
